//
//  CYInformationTableViewCell.m
//  cyydt
//
//  Created by chu on 2019/1/14.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYInformationTableViewCell.h"

@implementation CYInformationTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.dingLabel.layer.cornerRadius = 2;
    self.dingLabel.layer.borderColor = RGBOF(0xFF4C50).CGColor;
    self.dingLabel.layer.borderWidth = 1;
    self.dingLabel.layer.masksToBounds = YES;
}

- (void)setModel:(CYProjectModel *)model{
    _model = model;
    self.imageViewWidthConstraint.constant = 105;
    self.titleLabelMarginRIghtConstraint.constant = 5;
    self.imageViewHeightConstraint.constant = 76;
    
    if ([model.top integerValue] == 1) {
        //置顶
        self.dingLabel.text = @"  置顶  ";
        self.typeLabel.text = model.catname;
        self.timeLabel.text = model.created_time;
        if ([model.type integerValue] == 4) {
            self.commentCountLabel.text = [NSString stringWithFormat:@"%@回答",model.answer_number];
        }else{
            self.commentCountLabel.text = [NSString stringWithFormat:@"%@评论",model.comment_number];
        }
        self.titleLabelMarginRIghtConstraint.constant = 0;
        self.titleLabel.text = model.title;
        [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageWithColor:[UIColor lightGrayColor] Size:self.headImageView.frame.size]];

    }else{
        if ([NSString stringIsNull:model.image]) {
            self.imageViewWidthConstraint.constant = 0;
            self.maringDingLabelLeftConstraint.constant = 0;
            self.titleLabelMarginRIghtConstraint.constant = 0;

            self.dingLabel.text = @"";
            self.typeLabel.text = model.catname;
            self.timeLabel.text = model.created_time;
            if ([model.type integerValue] == 4) {
                self.commentCountLabel.text = [NSString stringWithFormat:@"%@回答",model.answer_number];
            }else{
                self.commentCountLabel.text = [NSString stringWithFormat:@"%@评论",model.comment_number];
            }
            self.titleLabel.text = model.title;
        }else{
            self.maringDingLabelLeftConstraint.constant = 10;
            
            if ([model.hot integerValue] == 1) {
                //热门
                self.dingLabel.text = @"  热  ";
                self.typeLabel.text = model.catname;
                self.timeLabel.text = model.created_time;
                if ([model.type integerValue] == 4) {
                    self.commentCountLabel.text = [NSString stringWithFormat:@"%@回答",model.answer_number];
                }else{
                    self.commentCountLabel.text = [NSString stringWithFormat:@"%@评论",model.comment_number];
                }
                [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageWithColor:[UIColor lightGrayColor] Size:self.headImageView.frame.size]];
                self.titleLabel.text = model.title;
                
            }else{
                self.dingLabel.text = @"";
                self.maringDingLabelLeftConstraint.constant = 0;
                self.typeLabel.text = model.catname;
                self.timeLabel.text = model.created_time;
                if ([model.type integerValue] == 4) {
                    self.commentCountLabel.text = [NSString stringWithFormat:@"%@回答",model.answer_number];
                }else{
                    self.commentCountLabel.text = [NSString stringWithFormat:@"%@评论",model.comment_number];
                }
                [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageWithColor:[UIColor lightGrayColor] Size:self.headImageView.frame.size]];
                self.titleLabel.text = model.title;
                
            }
        }
        
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
